package com.yolib.sanyi.pic;

import com.yolib.sanyi.R;

import android.graphics.Bitmap;
import android.util.Log;
import android.widget.ImageView;
import android.widget.ProgressBar;

public class LoadCallback {
	
	public static int LOAD_SUCCESS = 0;
	public static int LOAD_FAIL = 1;
	
	public boolean isEdit = false; 
	
	private ImageView imageview;
	private ProgressBar bar;
	private String fb_id;
	
	public LoadCallback()
	{
		
	}
	
	public LoadCallback(ImageView mImageView)
	{
		imageview = mImageView;
	}
	
	public LoadCallback(ImageView mImageView, ProgressBar mBar)
	{
		imageview = mImageView;
		bar = mBar;
	}
	
	public ImageView getImageView()
	{
		return imageview;
	}
	
	public ProgressBar getProgressBar()
	{
		return bar;
	}
	
	public void setId(String id)
	{
		fb_id = id;
	}
	
	public void result(int status, String id,  Object object){
		if(status == LOAD_SUCCESS)
			{
				if(fb_id == id)
					{
					if(imageview instanceof PicImageView)
					{
						if(isEdit)
							((PicImageView) imageview).setEditIamgeView((Bitmap) object);
						else if(imageview.getWidth() > 200 )
							((PicImageView) imageview).setImageView((Bitmap) object, PicImageView.SIZE_LARGE);
						else
							((PicImageView) imageview).setImageView((Bitmap) object, PicImageView.SIZE_SMALL);
					}
					else
						imageview.setImageBitmap((Bitmap) object);
					}
			}
		else {
			imageview.setImageResource(R.drawable.ic_launcher);
		}
	};
	
	public void processing(int arg){};
}
